package com.baoteng.scan;

import android.app.Activity;
import android.content.res.AssetFileDescriptor;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.RelativeLayout;

/**
 * Author: loren
 * Date: 2019/9/17
 */
public class Scanner implements IScan {

    private IScan scanner;
    private static Scanner instance;

    public static Scanner getScanner() {
        if (instance == null) {
            synchronized (Scanner.class) {
                if (instance == null) {
                    instance = new Scanner();
                }
            }
        }
        return instance;
    }

    public Scanner() {
        scanner = ScannerImpl.getInstance();
    }

    @Override
    public void init(Activity con, RelativeLayout mContainer, RelativeLayout mCropLayout, AssetFileDescriptor file, SurfaceView surfaceView) {
        scanner.init(con, mContainer, mCropLayout, file, surfaceView);
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {
        scanner.surfaceDestroyed(holder);
    }

    @Override
    public void surfaceCreated(SurfaceHolder holder) {
        scanner.surfaceCreated(holder);
    }

    @Override
    public void actDestory() {
        scanner.actDestory();
    }

    @Override
    public void actPause() {
        scanner.actPause();
    }

    @Override
    public void switchFlashLight(boolean open) {
        scanner.switchFlashLight(open);
    }
}
